@extends('home/layout/master')
@section('title', $articleData->title."-".$configs["cfg_title"])
@section('keywords', $articleData->keywords)
@section('description', $articleData->description)
<meta name="csrf-token" content="{{ csrf_token() }}">

@section('body')
    <link rel="stylesheet" href="/plus/editormd/css/editormd.min.css" />
    <script src="/plus/editormd/lib/marked.min.js"></script>
    <script src="/plus/editormd/lib/prettify.min.js"></script>
    <script src="/plus/editormd/lib/raphael.min.js"></script>
    <script src="/plus/editormd/lib/underscore.min.js"></script>
    <script src="/plus/editormd/lib/sequence-diagram.min.js"></script>
    <script src="/plus/editormd/lib/flowchart.min.js"></script>
    <script src="/plus/editormd/lib/jquery.flowchart.min.js"></script>
    <script src="/plus/editormd/editormd.min.js"></script>
    <article>
        <!--lbox begin-->
        <div class="lbox">
            <div class="content_box whitebg">
                <h2 class="htitle">
                    <span class="con_nav">您现在的位置是：<a href="/">首页</a>
                        @foreach($crumbs as $v)
                        &nbsp;>&nbsp;<a href="{{ url('type/'.$v->id) }}">{{ $v->name }}</a>
                        @endforeach
                    </span>{{ $articleData->type_name }}
                </h2>
                <h1 class="con_tilte">{{ $articleData->title }}</h1>
                <p class="bloginfo"><i class="avatar"><img src="{{ $articleData->face ? $articleData->face : '/static/images/tx10.jpg' }}"></i><span></span><span>{{ date('Y-m-d', $articleData->addtime) }}</span><span>【{{ $articleData->type_name }}】</span><span>{{ $articleData->click }}人已围观</span></p>
                <p class="con_info"><b>简介</b>{{ $articleData->description }}</p>
                <div class="con_text" style="padding-right: 10px;">
                    @if($articleData->type == 1)
                    <div id="wordsView">
                        <textarea style="display:none;" name="editormd-markdown-doc">{{$articleData->body}}</textarea>
                    </div>
                    @else
                        {!! $articleData->body !!}
                    @endif
                    <p></p>
                    <br />
                    关注博客，更多精彩分享，敬请期待！<br />
                    &nbsp;
                    <p></p>
                    <p>Tags：
                        @foreach($tags as $v)
                        <a href="{{ url('tag/'. $v->id) }}" target="_blank">{{ $v->name }}</a>&nbsp;&nbsp;
                            @endforeach
                    </p>
                    <p class="share"><b>转载：</b>欢迎转载，如有侵权联系站长删除。企鹅：{{ $configs['cfg_qq'] }}</p>
                    <p>
                        <span class="diggit">
                            <a href="javascript:;" onclick="articlePraise({{ $articleData->id }})"> 很赞哦！ </a>
                            (<b id="praisenum">{{ $articleData->praise }}</b>)
                        </span>
                    </p>
                    <div class="nextinfo">
                        <p>上一篇：<a href='{{ empty($prev->id) ? '/' : url('article/'.$prev->id) }}'>{{ isset($prev->title) ? $prev->title : "" }}</a></p>
                        <p>下一篇：<a href='{{ empty($next->id) ? '/' : url('article/'.$next->id) }}'>{{ isset($next->title) ? $next->title : "" }}</a></p>
                    </div>
                </div>
            </div>
            <div class="whitebg">
                <h2 class="htitle">相关文章</h2>
                <ul class="otherlink">
                    @foreach($newArticleData as $v)
                    <li><a href="{{ url('/article/'.$v->id) }}" title="{{ $v->title }}">{{ $v->title }}</a></li>
                    @endforeach
                </ul>
            </div>
            <div class="whitebg">
                <h2 class="htitle">随机图文</h2>
                <ul class="xiangsi">
                    @foreach($articleTw as $v)
                    <li><a href="{{ url('/article/'.$v->id) }}" target="_blank"><i><img src="{{ $v->picname }}"></i>
                            <p>{{ $v->title }}</p>
                            <span>{{ $v->description }}</span></a></li>
                    @endforeach
                </ul>
            </div>
            <div class="whitebg gbook">
                <h2 class="htitle">文章评论</h2>
                @foreach($comment as $v)
                <div style="border-bottom: 1px dashed #ccc;">
                    <div><span style="color: #3299BB;font-weight: bold;">留言：</span>{{$v->nickname}}</div>
                    <div style="text-indent: 3em;">{{$v->content}}</div>
                    @if($v['reply'] != "")
                    <div><span style="color: #FE4365;font-weight: bold;margin-top: 5px;">回复：</span></div>
                    <div style="text-indent: 2em;">{{$v->reply}}</div>
                    @endif
                </div>
                @endforeach
                <div>
                    <div style="margin-top: 10px;">
                        昵称：<input type="text" name="nickname">
                    </div>
                    <div style="margin-top: 10px;">
                        邮箱：<input type="text" name="email">
                    </div>
                    <div style="margin-top: 10px;">
                        内容：<textarea name="content" rows="5" cols="30"></textarea>
                    </div>
                        @csrf
                    <div style="margin-top: 10px;margin-left: 45px;">
                        <button onclick="articleComment({{ $articleData->id }})">提交</button>
                    </div>
                </div>
            </div>
        </div>
        <!--lbox end-->
        <div class="rbox">
            <div class="whitebg paihang">
                <h2 class="htitle">点击排行</h2>
                @foreach($articleClick as $k=>$v)
                    <section class="topnews imgscale"><a href="{{ url('/article/'.$v->id) }}"><img src="{{ empty($v->picname) ? '/static/images/b02.jpg' : $v->picname }}" alt="{{ $v->title }}" title="{{ $v->title }}"><span>{{ $v->title }}</span></a></section>
                    <?php if($k == 0){ break; } ?>
                @endforeach
                <ul>
                    @foreach($articleClick as $k=>$v)
                        <?php if($k == 0){ continue; } ?>
                        <li><i></i><a href="{{ url('/article/'.$v->id) }}" title="{{ $v->title }}" target="_blank">{{ $v->title }}</a></li>
                    @endforeach
                </ul>
            </div>
            <div class="whitebg tuijian">
                <h2 class="htitle">本栏推荐</h2>
                @foreach($articlePraise as $k=>$v)
                    <section class="topnews imgscale"><a href="{{ url('/article/'.$v->id) }}"><img src="{{ empty($v->picname) ? '/static/images/2.jpg' : $v->picname }}" alt="{{ $v->title }}" title="{{ $v->title }}"><span>{{ $v->title }}</span></a></section>
                    <?php if($k == 0){ break; } ?>
                @endforeach
                <ul>
                    @foreach($articlePraise as $k=>$v)
                        <?php if($k == 0){ continue; } ?>
                        <li><a href="{{ url('/article/'.$v->id) }}" title="{{ $v->title }}" target="_blank"><i><img src="{{ empty($v->picname) ? '/static/images/2.jpg' : $v->picname }}"></i>
                                <p>{{ $v->title }}</p>
                            </a></li>
                    @endforeach
                </ul>
            </div>
            <div class="ad whitebg imgscale">
                <ul>
                    <a href='/' target=_blank><img src="{{asset('/static/images/ad.jpg')}}"></a>      </ul>
            </div>
            <div class="whitebg cloud">
                <h2 class="htitle">标签云</h2>
                <ul>
                    @foreach($tagsData as $v)
                        <a href="{{ url('/tag/'.$v->id) }}" target="_blank">{{ $v->name }}</a>
                    @endforeach
                        <a href="{{ url('/tags/') }}">所有标签</a>
                </ul>
            </div>

            <div class="ad whitebg imgscale">
                <ul>
                    <a href='/' target=_blank><img src="{{asset('/static/images/ad02.jpg')}}"></a>      </ul>
            </div>
            <div class="card">
                <h2>我的名片</h2>
                <p>网名：随心</p>
                <p>职业：PHP程序员</p>
                <p>现居：湖北省-武汉市</p>
                <p>Email：{{ $configs["cfg_email"] }}</p>
                <ul class="linkmore">
                    <li><a href="/" target="_blank" class="iconfont icon-zhuye" title="网站地址"></a></li>
                    <li><a href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email={{ $configs['cfg_email'] }}" target="_blank" class="iconfont icon-youxiang" title="我的邮箱"></a></li>
                    <li><a href="http://wpa.qq.com/msgrd?v=3&amp;uin={{ $configs['cfg_qq'] }}&amp;site=qq&amp;menu=yes" target="_blank" class="iconfont icon---" title="QQ联系我"></a></li>
                    <li id="weixin"><a href="#" target="_blank" class="iconfont icon-weixin" title="关注我的微信"></a><i><img src="{{asset('/static/images/wx.jpg')}}"></i></li>      </ul>
            </div>
        </div>
    </article>
    <script>

        $(function(){
            editormd.markdownToHTML("wordsView", {
                htmlDecode: "style,script,iframe",
                emoji: false,
                taskList: true,
                tex: true,
                flowChart: true,
                sequenceDiagram: true,

            });
        });

        // 点赞
        function articlePraise(id)
        {
            $.ajax({
                url:"/praise/"+id,
                type:'get',
                dataType:'json',
                success:function(re)
                {
                    if (re.status == 1){
                        $("#praisenum").html(re.msg);
                        alert("点赞成功");
                    } else {
                        alert(re.msg);
                    }
                }

            })
        }

        // 留言
        function articleComment(id){
            $.ajax({
                url:"/comment/",
                type:'POST',
                dataType:'json',
                data:{article_id:id,nickname:$("[name='nickname']").val(),email:$("[name='email']").val(),content:$("[name='content']").val()},
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                success:function(re)
                {
                    if (re.status == 1){
                        alert(re.msg);
                    } else {
                        alert(re.msg);
                    }
                }
            })
        }
    </script>
    @endsection
